package com.example.demo.study.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class Meta {
    @MyAnno(str = "Example" , val = 40)
    public static void math(){
       Meta ob=new Meta();
       try{
           Class<?> c=ob.getClass();
           Method m=c.getMethod("math");
           MyAnno myAnno=m.getAnnotation(MyAnno.class);
           System.out.println(myAnno.str()+"  "+myAnno.val());
       } catch (NoSuchMethodException e) {
           e.printStackTrace();
       }
    }

    @Description(description = "hello world")
    @MyAnno(str = "King" ,val = 88)
    public static void find()  {
         Meta ob=new Meta();
         Class<?> c=ob.getClass();
         try{
             Method m=c.getMethod("find");
             Annotation[] annotations= m.getAnnotations();
             for(Annotation a:annotations)
             {
                 System.out.println(a);
             }
         }catch (NoSuchMethodException e)
         {
             e.printStackTrace();
         }


    }

    public static void main(String[] args) {
        math();
        find();
    }
}
